<?
  require_once("connection.php");
  error_reporting(0);
?>
	<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery('.mydatepicker').datepicker({
			dateFormat : 'yy-mm-dd'
		});
	});
	</script>
<table>
  <tbody>
    <tr>
      <td>Course name</td>
      <td>
      <?
    if(isset($_POST["course_id"]))
      $course_id=$_POST["course_id"];
    else
      $course_id=0;

    $query = "select * from g_courses;";
    $result = @mysql_query($query);

      if($_POST["oper"]==0){

	    echo "<select id='course_select'>";
	    if($course_id==0)
	      echo "<option value='0' selected>All Courses</option>";
	    else
          echo "<option value='0'>All Courses</option>";
	    while($row=@mysql_fetch_array($result)){
          if($course_id==$row["course_id"])
            echo "<option value='".$row["course_id"]."' selected>".$row["name"]." - ".$row["year"]." ".$row["semester"]."</option>";
          else
            echo "<option value='".$row["course_id"]."'>".$row["name"]." - ".$row["year"]." ".$row["semester"]."</option>";
	    }
	    echo "</select>";
	  }
	  else
        if($_POST["oper"]==1){
            $query1 = "select * from g_lectures where lecture_id=".$_POST["rec"].";";
            $result1 =@mysql_query($query1);
            $row_edit1 = @mysql_fetch_array($result1);

     	    echo "<select id='course_select'>";
            echo "<option value='0'>All Courses</option>";
	        while($row=@mysql_fetch_array($result)){
              if($row_edit1["course_id"]==$row["course_id"])
                echo "<option value='".$row["course_id"]."' selected>".$row["name"]." - ".$row["year"]." ".$row["semester"]."</option>";
              else
                echo "<option value='".$row["course_id"]."'>".$row["name"]." - ".$row["year"]." ".$row["semester"]."</option>";
	        }
	        echo "</select>";
        }
      ?>
      </td>
    </tr>
    <tr>
      <td>sequence number</td>
      <?
        if($_POST["oper"]==0)
          echo "<td><input id='seq_num' type='text' size='40' maxlength='100'/></td>";
        else
          if($_POST["oper"]==1){
            echo "<td><input id='seq_num' value='".$row_edit1["seq_num"]."' type='text' size='40' maxlength='100'/></td>";
          }
      ?>
    </tr>
    <tr>
      <td>date</td>
      <?
        if($_POST["oper"]==0)
          echo "<td><input class='mydatepicker' id='date' type='text' size='40' maxlength='10'/></td>";
        else
          if($_POST["oper"]==1){
            echo "<td><input class='mydatepicker' id='date' value='".$row_edit1["date"]."' type='text' size='40' maxlength='10'/></td>";
          }
      ?>
    </tr>
    <tr>
      <td>description</td>
      <?
        if($_POST["oper"]==0)
          echo "<td><input id='description' type='text' size='40' maxlength='200'/></td>";
        else
          if($_POST["oper"]==1){
            echo "<td><input id='description' value='".$row_edit1["description"]."' type='text' size='40' maxlength='200'/></td>";
          }
      ?>
    </tr>
    <!--<tr>
      <td>slide</td>
      <?
        if($_POST["oper"]==0){
          //echo "<td><input id='slide' type='text' size='40' maxlength='200'/></td>";
          //echo "<td><input id='slide' type='file' /></td>";
          echo "<td><input id='upload_image_button' type='button' value='Upload Image' /></td>";
        }
        else
          if($_POST["oper"]==1){
            echo "<td><input id='slide' value='".$row_edit1["slide"]."' type='text' size='40' maxlength='200'/></td>";
          }
      ?>
    </tr>
    <tr>
      <td>additional</td>
      <?
        if($_POST["oper"]==0)
          echo "<td><input id='additional' type='text' size='40' maxlength='200'/></td>";
        else
          if($_POST["oper"]==1){
            echo "<td><input id='additional' value='".$row_edit1["additional"]."' type='text' size='40' maxlength='200'/></td>";
          }
      ?>
    </tr>-->
    <tr>
      <td>&nbsp</td>
      <td align="right">
      <?
        echo "<button onclick='display_table(2,0);return false;'>Back</button>";
        if($_POST["oper"]==0)
          echo "<button onclick='save_lecture(0,0);return false;'>Add</button>";
        else
          if($_POST["oper"]==1)
            echo "<button onclick='save_lecture(1, ".$_POST["rec"].");return false;'>Edit</button>";
      ?>
      </td>
    </tr>
  </tbody>
</table>
<!--<input id='upload_image_button' type='button' value='Upload Image' />-->
